<script>
	var url;
	$(document).ready(function(){
		
		// load grid
		$(function(){
			$('#dg').datagrid({url:"<?=base_url()?>lap_lulus/grid"});	
			//$('#dg').datagrid('enableFilter'); 			
		});	
		
		// onchange
		$('#s_kd_fakultas').change(function(){
			$('#s_kd_prodi').load(base_url+'prosedur/getProdibyFakultas/'+$('#s_kd_fakultas').val());
		});
		
		// filter
		filter = function(){
			$('#dg').datagrid('load',{
				kd_fakultas : $('#s_kd_fakultas').val(),
				kd_prodi : $('#s_kd_prodi').val(),
				PMBPeriodID : $('#s_PMBPeriodID').val(),
			});
			//$('#dg').datagrid('enableFilter');
		}
		
		//# Tombol Bawah
		$(function(){
			var pager = $('#dg').datagrid().datagrid('getPager');	// get the pager of datagrid
			pager.pagination({
				buttons:[
					{
						iconCls:'icon-print',
						text:'Export PDF',
						handler:function(){
						var kd_fakultas = $('#s_kd_fakultas').val();
						var kd_prodi = $('#s_kd_prodi').val();
						var PMBPeriodID = $('#s_PMBPeriodID').val();
						if(kd_prodi !='' && PMBPeriodID !=''){
							window.open('<?=base_url().'lap_lulus/laporan_pdf'?>/'+$('#s_kd_prodi').val()+'/'+$('#s_PMBPeriodID').val());
						}
						else{
								$.messager.show({
									title: 'Warning',
									msg: 'Harap Isi Filter Terlabih Dahulu'
								});
							}
						}
					},
					{
						iconCls:'icon-excel',
						text:'Export EXCEL',
						handler:function(){
							window.open('<?=base_url().'lap_lulus/laporan_excel'?>');
						}
					}
				]
			});			
		});
		
		
	});
</script>

<table id="dg" title="Laporan Hasil Seleksi Ujian Saringan" data-options="
			rownumbers:true,
			singleSelect:true,
			autoRowHeight:false,
			pagination:true,
			pageSize:30,
			fit:true,
			toolbar:'#toolbar',
			">
	<thead>
		<tr>
			<!--<th field="tahun_penerimaan" sortable="true" width="80">Tahun Penerimaan</th> -->
			<th field="no_pendaftaran" sortable="true" width="100">No Pendaftaran</th>
			<th field="nama" sortable="true" width="100">Nama</th>
			<th field="alamat" sortable="true" width="200">Alamat</th>
			<th field="no_telp" sortable="true" width="100">Telepon Siswa</th>
			<th field="nama_ortu" sortable="true" width="150">Nama Orang Tua / Wali</th>
			<th field="alamat_ortu" sortable="true" width="150">Alamat Orang Tua / Wali</th>
			<th field="pekerjaan" sortable="true" width="100">Pekerjaan</th>
			<th field="status" sortable="true" width="100">Status</th>			
		</tr>
	</thead>
</table>
<div id="toolbar" style="padding:5px;height:auto">
	<div class="fsearch">
		<table width="700" border="0">
		  <tr>
			<td>Fakultas</td>
			<td>: 
				<select id="s_kd_fakultas" name="s_kd_fakultas" style="width:290px;">
					<?=$this->mdl_prosedur->OptionFakultas();?>
				</select>
			</td>
			<td>&nbsp;</td>
			<td>Periode PMB</td>
			<td>: 
				<select id="s_PMBPeriodID" name="s_PMBPeriodID" style="width:90px;">
					<?=$this->mdl_prosedur->OptionJadwalPMB();?>
				</select>
			</td>
		  </tr>
		  <tr>
			<td>Program Studi</td>
			<td>: 
				<select id="s_kd_prodi" name="s_kd_prodi" style="width:290px;">
					<?=$this->mdl_prosedur->OptionProdi();?>
				</select>
			</td>
			<td>&nbsp;</td>
			<td>&nbsp;</td>
			<td>&nbsp;&nbsp;<a href="#" onclick="filter()" class="easyui-linkbutton" iconCls="icon-search">Filter</a></td>
		  </tr>
		</table>
	</div>
</div>
